package de.upb.aquarium.api.objects;

import javax.media.opengl.GL;

/**
 * 3D-Object that changes its position/rotation dependend on the elapsed time.
 * @author Alexander
 */
public class MovingObject extends General3DObject {

	General3DObject object;
	IPathCalculator pathCalculator;
	
	public MovingObject(General3DObject object, IPathCalculator pathCalculator) {
		super();
		this.object = object;
		this.pathCalculator = pathCalculator;
	}


	@Override
	public void paint(GL gl) {
		beforeRendering(gl);

		//float[] pos = pathCalculator.nextPosition();
		//TODO: move to new position, depends on something like: timeElapsed * speedFactor
		//rotate the object, object needs two specified points that must be on the pathline
		object.setPosition(pathCalculator.nextPosition());
		object.setRotation(90f, pathCalculator.calculateRotation(), 0f);
		object.paint(gl);
		afterRendering(gl);
	}

}
